#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int len = s.size();
	while (n--)
	{
		string s1;
		cin >> s1;
		int cnt = 0;
		for (int i = 0; i < len;i++)
		{
			if (s.substr(i,s1.size()) == s1)
			{
				cnt++;
				i = i + s1.size();
				i--;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}